package com.jiyi.widget.picselect;


import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.swift.maintenance.R;
import com.swift.utils.GlideUtil;

public class PicsAdapter extends BaseAdapter {

	private Context context ;
	private List<String> xiuList;
	int layoutResId = 0;
	public PicsAdapter(Context context , List<String> xiuList) {
		this.context = context ;
		this.xiuList = xiuList ;
	}
	
	public PicsAdapter(Context context , List<String> xiuList,int layoutResId) {
		this.context = context ;
		this.xiuList = xiuList ;
		this.layoutResId = layoutResId;
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return xiuList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final ViewHolder viewHolder;
		if(convertView == null){
			viewHolder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(layoutResId == 0 ?R.layout.item_xiu : layoutResId, parent, false);
			viewHolder.iv_simple = (ImageView) convertView.findViewById(R.id.iv_simple);
			convertView.setTag(viewHolder);
		}else{
			viewHolder = (ViewHolder) convertView.getTag();
		}
		
		String xiu = xiuList.get(position);
		GlideUtil.load(context, xiu,viewHolder.iv_simple);
		return convertView;
	}
	
	class ViewHolder {		
		private ImageView iv_simple;
	}
}
